<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ include file="/common/common.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/sys/role/";  //应用的地址名
String listActionName = basePath+"SysModelRole.action?op=searchjs";
String addActionName = basePath+"SysModelRole_add.action";
String editActionName = basePath+"SysModelRole_modify.action";
String delActionName = basePath+"SysModelRole_del.action?op=deljs";
String relationUserActionName = basePath+"SysModelRole_relation.action";
String viewRelationUserActionName = basePath+"SysModelRole_viewRelationUser.action";
%>
<script type="text/javascript">
    		$(function(){
			//表格初始化
			$('#searchTable').grid({
				//title:'<div style="text-align:center;font-size:17">系统角色表</div>',
				title:[<ce:menu/>],
				url:'<%=listActionName%>',
				queryParams:{"search.names":"","search.cxMenuId":"<s:property value="search.cxMenuId"/>"},  //用于查询的参数以及初始值
				//表头列，不建议改动
				frozenColumns:[[   
	                {field:'ck',checkbox:true}
				]],
				//数据列，根据显示的内容进行修改
				columns:[[   
						{field:'vcName',title:'角色名称',width:120,sortable:true,formatter:function(value,row,index){
						    if(row.vcId == "admin" || row.vcId == "common")  //当为系统内置的管理员和通用角色时，文字颜色设置为红色
						         return '<font color="red">'+value+'</font>';
						     else    
						         return  value;      
						}},
						{field:'vcMemo',title:'角色描述',width:200},
						{field:'vcSeq',title:'排序号',width:80,sortable:true}
					<ce:includeColum optName="relation">
						,{field:"opt",title:'操作',width:150,formatter:function(value,row,index){
						   return '<a href="javascript:openRoleUserListPage(\''+row.vcId+'\',\''+row.vcName+'\')">查看关联账号</a>';
						} }
		            </ce:includeColum>
				]],
				//功能按钮组
				toolbar:[<ce:jsonBtn/>]
			});
			//查询操作
			$('#search').click(function(){
		            defaultSearchAction();
            });		
		});	
		
		//点击添加按钮后的操作：打开添加界面
        function openAddPage(){
            defaultOpenAddPageHavebtn('<%=addActionName%>?menuId=<s:property value="search.cxMenuId"/>',600,400);
		}
		//点击编辑按钮后的操作：打开编辑界面
		function openModifyPage(){
            defaultOpenModifyPageHavebtn('<%=editActionName%>?menuId=<s:property value="search.cxMenuId"/>',600,400);
		}
		//打开角色管理账号的设置界面
		function openRelationUserPage(){
		    var rows = $('#searchTable').datagrid('getSelections');					
			if (rows.length>1){
			   $.messager.alert('消息提示','请选择一个角色进行操作','error');
			}else if(rows.length==1){
               defaultOpenWindow('<%=relationUserActionName%>?op=openRelationUserPage&roleId='+rows[0].vcId,'账号角色关联操作：当前角色【'+rows[0].vcName+'】',550,450,'','',{but:[{id:'addBtn',name:'保存',classname:'icon-save'}]});
            }else{
		       $.messager.alert('消息提示','请选择要关联的角色数据','error');
		   }   
		}
		//打开查看角色关联账号的界面
		function openRoleUserListPage(roleId,roleName){
            defaultOpenWindow('<%=viewRelationUserActionName%>?roleId='+roleId,'【'+roleName+'】角色对应账号',300,350);
		}
		//删除数据操作
		function deleteItems(){
            defaultDeleteItems('<%=delActionName%>');
		}
		//点击帮助按钮后的操作：打开帮助界面
		function openHelpPage(){
		    defaultOpenWindow('<%=path%>/sys/menu/SysMenuHelp_look.action?chkSelf=<%=request.getAttribute("menuId").toString() %>','帮助信息查看',600,600);
		}
    
    </script>
<html>
  <head>
    <base href="<%=basePath%>"></base>
    <title><%=com.ce.util.RegeditUtil.getRegeditStringValue("SYSTEM_SEG_NAME") %></title>
  </head> 
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" >

<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr height="30">
    <td>
    <div id="searchDiv" class="searchDiv">
     <div id="searchLeft" style=" width:85%; float:left">
       <div id="searchWrite"  class="searchWrite">
        角色名称：<input type="text" id="names" name="names">
       </div>       
     </div>
     <div id="searchRight" class="searchRight">
      <a id="search" href="javascript:void(0)"  class="easyui-linkbutton" iconCls="icon-search">查询</a>
     </div>
   </div></td>
  </tr>
  <tr>
    <td colspan="2"><div id="searchTable"></div></td>
  </tr>
</table>
</body>
</html>
   
   

